~ chicken-core (master) /manual/Module (scheme load)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (scheme load)
5
6<procedure>(load filename [environment-specifier])</procedure>
7
8It is an error if filename is not a string.
9
10The load procedure reads expressions and definitions from the file designated
11by filename and evaluates
12them sequentially in the environment specified by
13environment-specifier. If
14environment-specifier is omitted, (interaction-environment) is assumed.
15
16The load procedure does not affect the values returned by current-input-port and
17current-output-port. It returns an unspecified value.
18
19CHICKEN offers a few extensions to the R7RS definition of {{load}}:
20
21* The environment specifier may also be a procedure of a single argument taking a expression and is used to evaluate every toplevel expression read from the input file, if the file contains Scheme source code.
22
23* On platforms that support it (currently BSD, Haiku, MacOS X, Linux, Solaris, and Windows), {{load}} can be used to load shared objects.
24
25Example for loading compiled programs:
26
27 % cat x.scm
28 (define (hello) (print "Hello!"))
29 % csc -s x.scm
30 % csi -q
31 #;1> (load "x.so")
32 ; loading x.so ...
33 #;2> (hello)
34 Hello!
35 #;3>
36
37There are some limitations and caveats to the CHICKEN extensions you
38need to be aware of:
39
40* The second argument to {{load}} is ignored when loading compiled code.
41* A compiled file can only be loaded once. Subsequent attempts to load the same file have no effect.
42
43---
44Previous: [[Module (scheme lazy)]]
45
46Next: [[Module (scheme process-context)]]